class AdminMoviesController < ApplicationController
  before_filter :authorize
  layout 'layouts/admin_layout'
  
  def index
    if params[:movies] == 'on_show'
    @movies = Movie.find_all_by_show_status('on')
    else
      if 'off_show' == params[:movies]
        @movies = Movie.find_all_by_show_status('off')
      end
    end
  end
  
  def show
    @movie = Movie.find params[:id]
  end
  
  def edit
    @movie = Movie.find(params[:id])
  end
  
  def new
  end
  
  def destroy
    @movie = Movie.find(params[:id])
    movies = @movie.show_status
    @movie.destroy
    flash[:notice] = "The movie information destroied successfully!"
    puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    puts movies
    redirect_to on_show_url if movies == "on"
    redirect_to off_show_url if movies == "off"
  end
  
  def update
    @movie = Movie.find(params[:id])
    if @movie.update_attributes(params[:movie])
      flash[:notice] = "The movie information updated successfully!"
      redirect_to admin_movie_url(:id => params[:id])
    else
      render :back
    end
  end
  
  def create
  end
  
end
